<?php
namespace app\process\session;

use app\common\repositories\im\ImSessionMemberRepository;
use app\common\repositories\im\ImSessionRepository;
use support\Container;
use Workerman\Crontab\Crontab;

class BroadcastSession
{
    public function onWorkerStart()
    {
        // 每5秒执行一次
        new Crontab('*/30 * * * * *', function(){
            [$total] = Container::make(ImSessionMemberRepository::class)->broadcastSession();
            echo "broadcast session: {$total}个会话\n";
        });
    }
}
